package adapter;import java.util.List;

import com.wonyesoft.wuliu.R;


import javabeen.CarTypeBeen;
import javabeen.LinkManBeen;
import adapter.CarTypeListAdapter.ViewHolder;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class LinkManAdapter extends BaseAdapter {
	public List<LinkManBeen> linkManBeens;
	private int xml;
	private Context context;
	private LayoutInflater inflater;
	
	public LinkManAdapter(Context context,  List<LinkManBeen> linkManBeens,int xml){
		this.linkManBeens = linkManBeens;
		this.xml = xml;
		this.context = context;
		if (this.context != null) {
			this.inflater = LayoutInflater.from(context);
		}
	}
	
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return linkManBeens.size();
	}
	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return linkManBeens.get(position);
	}
	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewHolder;
		if (convertView == null) {
			convertView = inflater.inflate(xml, null);
			viewHolder = new ViewHolder();
			viewHolder.carownername=(TextView) convertView.findViewById(R.id.carownername);
			viewHolder.phone=(TextView) convertView.findViewById(R.id.phone);
			viewHolder.cartypename=(TextView) convertView.findViewById(R.id.cartypename);
			convertView.setTag(viewHolder);
		}else {
			viewHolder=(ViewHolder) convertView.getTag();
		}
		LinkManBeen data=linkManBeens.get(position);
		if (data != null) {
			viewHolder.carownername.setText(data.getCarownername());
			viewHolder.phone.setText(data.getPhone());
			viewHolder.cartypename.setText(data.getCartypename());
		}
		return convertView;
	}
	
	class ViewHolder {
		
		TextView carownername;
		TextView phone;
		TextView cartypename;
	}
	
}
